<?
    final class DictionariesController extends PrincipioLab_Controller_Action
    {
        public function init()
        {
            parent::init();
            $this->view->menu = array(
                                "Delete" => "delete"
            );
        }


        public function indexAction()
        {
            if ($this->is_post)
                $this->view->title = "Dictionaries (Not Implemented)";
        }
               
        /*
        public function addAction()
	    {
            if ($this->is_post)
            {
                $this->view->title = "Add a new firmware";

                $this->view->is_add = true;
                $this->view->model_firmware = new Principio_Model_Firmware();

                if ($this->is_apply)
		        {
        */
                    /*
                    if ($this->validate())
                    {
                        if (($type_id = Principio_Model_TypeMapper::save($this->view->model_type)) !== false)
                        {
                            $this->view->model_type->setID($type_id);
                            Principio_Common::$msg = "Type was successfully added";
                            $this->view->is_add = false;
                            $this->view->action = "edit";
                            $this->view->title = "View and Edit type [".$this->view->model_type->getCaption()."]";
                        };
                    };
                    */

        /*
                };
            };
	    }


        public function editAction()
        {
            if (($this->is_post) && ($this->checkPostItemInt("id", "Firmware ID")))
            {
                $this->view->is_add = false;
                $this->view->action = "edit";
                $this->view->model_firmware = Principio_Model_FirmwareMapper::get($this->post_data['id']);
                $model_firmware_old = Principio_Model_FirmwareMapper::get($this->post_data['id']);

                if (($this->is_apply) && ($this->validate(true)))
                {
                    if (Principio_Model_FirmwareMapper::save($this->view->model_firmware))
                        Principio_Common::$msg = "Firmware was updated.";
                };

                $this->view->title = "View and Edit firmware [".(Principio_Common::$is_error ? $model_firmware_old->getCaption() : $this->view->model_firmware->getCaption())."]";
            };
        }


        public function deleteAction()
        {
            if ($this->is_post)
            {
                if ($this->checkPostItemInt("id", "Firmware ID"))
                {
                    if (Principio_Model_FirmwareMapper::delete($this->post_data["id"]))
                        Principio_Common::$msg = "Firmware was deleted.";
                };
            };
        }


        private function validate($is_edit = false)
        {
            if ($this->checkPostItemString("caption", "Caption"))
                $this->view->model_firmware->setCaption($this->post_data['caption']);

            if ($this->checkPostItemString("version", "version"))
                $this->view->model_firmware->setVersion($this->post_data['version']);

            if (!Principio_Common::$is_error)
            {
                Principio_Common::checkValidity(Principio_Model_FirmwareMapper::checkUniqueCaption($this->view->model_firmware), "Firmware with caption '".$this->view->model_firmware->getCaption()."' already exists");
                if (!$is_edit)
                {
                    // TODO : Check for firmware file unique
                //Principio_Common::checkValidity(Principio_Model_FirmwareMapper::checkUniqueTy($this->view->model_type), "SPA Type with type '".$this->view->model_type->getType()."' already exists");
                };
            };

            return !Principio_Common::$is_error;
        }
        */
}